#include "Pickup.h"
	Pickup::Pickup()
		:Component("Pickup")
	{
	}

	Pickup::~Pickup(void)
	{
	}

	void Pickup::Log(int32 d)
	{
	}


	void Pickup::addedToObject()
	{
		requestMessage("Picking",&Pickup::PickObj); 
	}

	/*uint32 Pickup::CheckPickingInCell(D3DXVECTOR2* pos)
	{
		return m_world->GetCurCellFid();
	}

	uint32 Pickup::CheckPickingInWorld(D3DXVECTOR2* pos)
	{
		Ray* mouseRay=m_coord->ScreenToWorldCoord(pos);
		float minObj=1000.0f;
		int fid=-1;;
		for(vector<FIGURE>::iterator iter=m_fManager->m_data.begin();iter<m_fManager->m_data.end();iter++)
		{
			float dist;
			if(mouseRay->Intersects(*iter->aabb,&dist))
			{
				if(dist<minObj)
				{
					fid=iter->id;
					minObj=dist;
				}
			}
		}
		Log(fid);
		delete mouseRay;
		return fid;
	}

	void Pickup::PickCell(World* w,D3DXVECTOR2* pos)
	{

	}

	void Pickup::Picking(Menu* m,D3DXVECTOR2* pos)
	{
		int32 id=-1;
		if(id=m->GetMenuID(pos))
		{
		}
		else
		{
			PickObj(m,pos);
		}
	}*/

	D3DXVECTOR3 Pickup::GetCellPos(D3DXVECTOR2 pos)
	{
		D3DXVECTOR3 rtp(0.0f,0.0f,0.0f);
		sendMessage("GetCellPos",&rtp);
		return rtp;
	}

	void Pickup::PickObj(const Message & msg)
	{
		vector<boost::any>* pa=boost::any_cast<vector<boost::any>*>(msg.p);
		vector<boost::any>::iterator iter=pa->begin();
		bool* rt=boost::any_cast<bool*>(*++iter);
		D3DXVECTOR3 wpos=D3DXVECTOR3(0.0f,0.0f,0.0f);
		int32 fid=-1;
		vector<boost::any> any;
		any.push_back(&wpos);
		any.push_back(&fid);
		sendMessage("GetCellPos",&any);
		if(wpos!=D3DXVECTOR3(0.0f,0.0f,0.0f))
		{
			sendMessage("AddBattleMenu",wpos);
			sendMessage("CurActFig",fid);
			*rt=true;
		}
		else
		{
			sendMessage("DeleteBattleMenu");
			*rt=false;
		}
	}